import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import '@/index.css'
import Root,{ loader as rootLoader } from '@/components/root'
import ErrorPage from '@/err-page'
import Contact from '@/components/contact'
// import App from './App.tsx'
import {createBrowserRouter,RouterProvider} from 'react-router-dom'

// 2. 创建 browser router
const router = createBrowserRouter([
  // 路由配置
  { path: '/', 
    element: <Root/>,
     errorElement: <ErrorPage />,
     loader:rootLoader,
    children:[
      // 官方推荐-> 子路由得path不要以 `/ ` 开头
      {path:'contacts/:id',element:<Contact />}
    ]},
])

createRoot(document.getElementById('root')!).render(
  <StrictMode>
    {/* <App /> */}
    <RouterProvider router={router} />
  </StrictMode>,
)
